<?php
  function govt_orders_validation($form) { 
	
//print_r($form); die;
    $stat = new set_static_variable(); 
	
	//Concerned dept validation
	     //chk_concerned_dept($form['field_go_depart']); 
		 
    //Duplicate Title
	//check_go_title_duplication($form['title'], $form['type']['#value'], $form['field_go_depart'], 'field_go_depart',$form['field_go_date'],'field_go_date',$stat->get_nid());
	
    $stat->set_nid(0);
		
    // Check bad character validation
   
   	chkbadchar($form['field_go_abstract']['und'][0]['value']['#value'], $form['field_go_abstract']['und'][0]['value']['#title'],'field_go_abstract');
    chkbadchar($form['title']['#value'], $form['title']['#title'],'title'); 
	chkbadchar($form['field_go_keywords']['und'][0]['value']['#value'],$form['field_go_keywords']['und'][0]['value']['#title'],'field_go_keywords'); 
	
	// district validation  
	
	
/*    if(sizeof($form['field_go_district']['und']['value']['#value'])>1 && $form['field_go_district']['und']['value']['#value'][0]==0){ 
     $field=$form['field_go_district']['und']['value']['#value'][0];
     $field_title=$form['field_go_district']['und']['#title'];
     form_set_error($field, $field_title . ' field can have either \'ALL\' or \'Other Districts\'');
       
    }*/
	
	distvalidation($form['field_go_district']['und']['#value']);
	/*if(sizeof($form['field_go_district']['und']['value']['#value'])>1 && $form['field_go_district']['und']['value']['#value'][0]==0){
    
    $field=$form['field_go_district']['und']['value']['#value'][0];
    $field_title=$form['field_go_district']['#title'];
     
    form_set_error($field, $field_title . ' field can have either \'ALL\' or \'Other Districts\'');
    
    }*/
										
	// minimum length charcter
  	minilength_validation($form['title']['#value'], 5, $form['title']['#title'], 'title');
  	minilength_validation($form['field_go_keywords']['und'][0]['value']['#value'], 5, $form['field_go_keywords']['und'][0]['value']['#title'],'field_go_keywords');
  	minilength_validation($form['field_go_abstract']['und'][0]['value']['#value'], 5, $form['field_go_abstract']['und'][0]['value']['#title'], 'field_go_abstract');
	
 	//maximum length validation for Title and Description Field
  	maxlength_validation($form['title']['#value'], 255, $form['title']['#title'], 'title');
	
	//print_r($form[field_go_date][und][0]['#value'] );										
											
	// Date Validation  

    //check_scheduler_date_expire($form['scheduler_settings']['unpublish_on']['date']['#value'],'Valid upto');
													
	check_date_expire($form['field_go_date']['und'][0]['value']['date']['#value'],$form['field_go_date']['und'][0]['value']['date']['#title']);
	
	
  // Form Type validtion
  url_validation($form['field_go_available_url']['und'][0]['value']['#value']);
  
if ($form['field_go_available_type']['und']['#value'] == 'download') { 
    // Validating the file size   
    //$field_obj = $form['field_act_file_upload']; 
	//$file_allowed_obj = $form_type;
	//print_r($form['field_act_file_upload']);
	$filename = $form['field_go_available_file']['und'][0]['#file']; 
	$filename->filename;
    file_upload_validation_D7($filename->filename,$form['field_go_available_type']['und']['#title']);  
  
  }
 
  
}
 function govt_orders_presave_validation($node) {
 	$reference_url = $node->field_go_available_url[0]['value'];
	 $node->field_go_available_url[0]['value'] = url_validation($reference_url);
   // $node->field_go_available_url[0]['value'] = url_validation($reference_url);
  } // function form_presave_validation() 